"""节日等活动"""

from flask import session
from app.libs.redprint import RedPrint
from app.validators.active import FollowForm
from app.libs.kunlun import KunLun
from app.errors import Success

api = RedPrint('active')


@api.route('/follows/2021-off', methods=['POST'])
def follows():
    """ScanV（云监测）2021年中钜惠:
       活动时间戒截止2021-08-31

    Returns:
        [type]: [description]
    """
    form = FollowForm().validate_for_api()
    form.follow_data.save()
    session.pop('smsCode', None)
    session.pop('contactsPhone', None)
    KunLun().active_follows({
        "activeName": form.follow_data.activeName,
        "fromURL": form.follow_data.fromURL,
        "contactsName": form.follow_data.contactsName,
        "company": form.follow_data.company,
        "contactsPhone": form.follow_data.contactsPhone,
        "contactsOccupation": form.follow_data.contactsOccupation,
        "industry": form.follow_data.industry,
        "interestedProduct": form.follow_data.interestedProduct,
    })
    return Success()
